<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
    <style>

    </style>
</head>

<body>
    <div id="app">
        <!-- 2.通过个标签属性，把父组件的数据传进来，而且是动态传入 -->
        <child :num="fatherNum"></child>
    </div>

    <template id="tmpl">
        <div>
            <!-- 3. 使用父组件传进来的num,也就是在子组件中使用父组件数据 -->
            <p>{{num}}</p>
        </div>
    </template>
</body>
<script>
    let child = {
        template: '#tmpl',
        props: ['num'] //1.先声明这个标签属性
    }

    var vm = new Vue({
        el: '#app',
        data: {
            fatherNum: 10
        },
        components: {
            child
        }
    })
</script>

</html>